#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
void reverse1(int arr[], int sz, int k)
{
	if (k >= sz)
	{
		k %= sz;
	}
	int i = 0;
	for (i = 0; i < k; i++)
	{
		int j = 0;
		int tmp = arr[sz - 1];
		for (j = sz-1; j > 0; j--)
		{
			arr[j] = arr[j - 1];
		}
		arr[0] = tmp;
	}
}
void reverse(int arr[], int left, int right)
{
	while (left < right)
	{
		int tmp = arr[left];
		arr[left] = arr[right];
		arr[right] = tmp;
		left++;
		right--;
	}
}
void turning(int arr[], int sz, int k)
{
	reverse(arr, 0, sz - k - 1);
	reverse(arr, sz-k, sz - 1);
	reverse(arr,0, sz - 1);
}
int main()
{
	int nums[] = { 1,2,3,4,5,6,7 };
	int sz = sizeof(nums) / sizeof(nums[0]);
	int k = 0;
	scanf("%d", &k);
	/*reverse1(nums, sz, k);*/
	turning(nums, sz, k);
	int i = 0;
	for (i = 0; i < sz; i++)
	{
		printf("%d ", nums[i]);
	}
}